<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>스타일 객체</title>
<script type="text/javascript">
var ctrl = {
		iframeResize: function() {
			var iframe = document.getElementById("testIframe");
			
			if (iframe.contentDocument) {
				//FF 3.0.11, Opera 9.63, and Chrome
				iframe.height = iframe.contentDocument.documentElement.scrollHeight + 20;
			} else if (iframe.contentWindow && iframe.contentWindow.document) {
				//IE6, IE7 and Chrome 
				iframe.height = iframe.contentWindow.document.body.scrollHeight + 20; 
			}
		},
		changeSRC: function(url) {
			var iframe = document.getElementById('testIframe');
			iframe.src = url;
		}
}
</script>
</head>
<body>
	<div>
		<button type="button" onclick="ctrl.changeSRC('8-1.html');">
				예제 8-1 보기</button>
		<button type="button" onclick="ctrl.changeSRC('8-2.html');">
				예제 8-2 보기</button>
	</div>
	<iframe id="testIframe" onload="ctrl.iframeResize(this)"></iframe>
	<div style="background-color: gray; height: 10px;"></div>
</body>
</html>
